//
//  GoodsInfoCell.swift
//  Box
//
//  Created by mn on 2025/4/2.
//

import UIKit
class GoodsInfoCell: UITableViewCell{
    
    let titleLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 17)
        label.textColor = .init(hex: "#292D32")
        label.numberOfLines = 0
        return label
    }()
    
    let specificationLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 15)
        label.textColor = .init(hex: "#333333")
        label.text = "规格"
        return label
    }()
    let specificationCountLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 15)
        label.textColor = .init(hex: "#333333")
        return label
    }()
    
    let postageLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 15)
        label.textColor = .gold
        label.text = "邮费金额"
        return label
    }()
    let priceLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 15)
        label.textColor = .gold
        return label
    }()
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
        selectionStyle = .none
        contentView.backgroundColor = .fromHex("#F4F6F8")
        let bg = UIView()
        bg.backgroundColor = .white
        contentView.addSubview(bg)
        bg.layer.cornerRadius = 16
        bg.snp.makeConstraints { make in
            make.edges.equalTo(UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16))
        }
        bg.addSubview(titleLabel)
        bg.addSubview(specificationLabel)
        bg.addSubview(specificationCountLabel)
        bg.addSubview(postageLabel)
        bg.addSubview(priceLabel)

        titleLabel.snp.makeConstraints { make in
            make.top.left.right.equalToSuperview().inset(16)
        }
        specificationLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().inset(16)
            make.top.equalTo(titleLabel.snp.bottom).offset(10)
        }
        
        specificationCountLabel.snp.makeConstraints { make in
            make.right.equalToSuperview().inset(16)
            make.centerY.equalTo(specificationLabel.snp.centerY)
        }
        postageLabel.snp.makeConstraints { make in
            make.left.equalToSuperview().inset(16)
            make.top.equalTo(specificationLabel.snp.bottom).offset(20)
        }
        
        priceLabel.snp.makeConstraints { make in
            make.right.equalToSuperview().inset(16)
            make.centerY.equalTo(postageLabel.snp.centerY)
            make.bottom.equalToSuperview().offset(-20)
        }
    }
    
}
